Skip to content

Fix CodeQL workflow: override TargetFrameworks to prevent iOS workload errors on Ubuntu - #463

Merged
jeff-at-trimble merged 5 commits into
developfrom
copilot/investigate-codeql-issues
Mar 26, 2026
Merged

Fix CodeQL workflow: override TargetFrameworks to prevent iOS workload errors on Ubuntu#463
jeff-at-trimble merged 5 commits into
developfrom
copilot/investigate-codeql-issues

Conversation

Copilot AI commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

CodeQL CI has been failing on ubuntu-latest due to three layered issues, each masking the next.

Changes

  • Rename codeql.ymlcodeql-analysis.yml — workflow was disabled via GitHub Actions UI; disabled state is keyed by file path
  • Add global.jsonubuntu-latest now ships .NET 10.0 pre-installed, which gets selected over 9.0. Pin to 9.0.x with rollForward: latestFeature
  • Use /p:TargetFrameworks=net9.0-android instead of -f net9.0-android — the core fix. -f sets TargetFramework for the inner build after project evaluation, but Microsoft.NET.Sdk.ImportWorkloads.targets runs during evaluation for ALL frameworks in TargetFrameworks. /p:TargetFrameworks= overrides at MSBuild's command-line priority, so the SDK never sees net9.0-ios/net9.0-maccatalyst
  • Build library project instead of solution — DemoApp isn't needed for CodeQL analysis, and avoids a second project with iOS targets
# Before: workload import fails for ios/maccatalyst during project evaluation
- run: dotnet restore Trimble.Modus.Components.sln
- run: dotnet build Trimble.Modus.Components.sln -f net9.0-android -c Release --no-restore

# After: TargetFrameworks override prevents iOS workload import entirely
- run: dotnet build Trimble.Modus.Components/Trimble.Modus.Components.csproj /p:TargetFrameworks=net9.0-android -c Release

📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

The custom CodeQL workflow was manually disabled in GitHub Actions UI.
A disabled workflow cannot be re-enabled through code changes alone.
Renaming the file creates a new active workflow, fixing code scanning.

Also improved workflow robustness:
- Added android workload installation
- Added explicit dotnet restore step
- Added DOTNET_NOLOGO and related env vars
- Used --no-restore flag on build step

Agent-Logs-Url: https://github.com/trimble-oss/modus-mobile-maui-components/sessions/e79135d3-6596-4540-9a4c-01b6806b0010

Co-authored-by: jeff-at-trimble <215895768+jeff-at-trimble@users.noreply.github.com>
Copilot AI changed the title [WIP] Investigate and propose fix for CodeQL scanning issue Fix CodeQL scanning by replacing manually disabled workflow Mar 26, 2026
Copilot AI requested a review from jeff-at-trimble March 26, 2026 15:45
coliff
coliff previously approved these changes Mar 26, 2026
@coliff
coliff marked this pull request as ready for review March 26, 2026 15:48
@coliff
coliff requested a review from rthanga1 as a code owner March 26, 2026 15:48
Copilot AI review requested due to automatic review settings March 26, 2026 15:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Restores reliable CodeQL scanning by replacing a manually-disabled workflow with a newly-registered workflow file and aligning the build steps with the repository’s CI approach.

Changes:

  • Replaced the disabled CodeQL workflow by introducing .github/workflows/codeql-analysis.yml (new workflow path).
  • Updated CodeQL build steps to install required workloads, run dotnet restore, and build with --no-restore.
  • Updated CODE_SCANNING_SETUP.md to document the root cause (manually-disabled workflow) and the new workflow filename.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
CODE_SCANNING_SETUP.md Updates documentation to reflect the new workflow file and guidance around duplicate configurations.
.github/workflows/codeql-analysis.yml Adds a new CodeQL workflow with explicit .NET MAUI build steps for CodeQL analysis.
Comments suppressed due to low confidence (3)

.github/workflows/codeql-analysis.yml:26

  • The job-level condition if: github.actor != 'dependabot[bot]' means CodeQL will never run on Dependabot PRs, so dependency update PRs won’t get CodeQL results/alerts until after merge (via push/schedule). If the skip is required due to token permission limits, consider documenting that in CODE_SCANNING_SETUP.md; otherwise consider removing the condition so PR scanning remains consistent for all contributors.
    .github/workflows/codeql-analysis.yml:43
  • actions/setup-dotnet here doesn’t match the CI workflow: CI sets include-prerelease: true for dotnet-version: 9.0.x. If this repo still relies on preview SDK builds, CodeQL will start failing to install the requested SDK on runners without prerelease enabled. Consider aligning with CI by adding include-prerelease: true (or pinning the exact SDK via global.json).
    .github/workflows/codeql-analysis.yml:47
  • This workflow builds net9.0-android but doesn’t pin/install a JDK, while the CI workflow explicitly installs Java 11. Relying on whatever Java happens to be preinstalled on ubuntu-latest can make the CodeQL build fragile when runner images change. Add an actions/setup-java@v4 step (matching CI) before installing workloads/building.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

ubuntu-latest has .NET 10.0.201 pre-installed. The dotnet CLI picks
the highest SDK, causing NETSDK1178 errors because MAUI workloads
installed for .NET 9 are incompatible with .NET 10.

global.json with rollForward:latestFeature pins to 9.0.xxx.

Agent-Logs-Url: https://github.com/trimble-oss/modus-mobile-maui-components/sessions/5b154b20-f9c6-438d-a543-4e9d4d4c4b1a

Co-authored-by: jeff-at-trimble <215895768+jeff-at-trimble@users.noreply.github.com>
Copilot AI changed the title Fix CodeQL scanning by replacing manually disabled workflow Fix CodeQL code scanning: re-enable disabled workflow and pin .NET SDK version Mar 26, 2026
@coliff
coliff self-requested a review March 26, 2026 15:59
coliff
coliff previously approved these changes Mar 26, 2026
The separate `dotnet restore Trimble.Modus.Components.sln` step restores
ALL target frameworks (including ios/maccatalyst) which aren't available
on Ubuntu. Removing it and letting `dotnet build -f net9.0-android`
handle both restore and build scopes everything to android only.

Agent-Logs-Url: https://github.com/trimble-oss/modus-mobile-maui-components/sessions/d85990fa-e435-43f7-9ecc-571eb3329b92

Co-authored-by: jeff-at-trimble <215895768+jeff-at-trimble@users.noreply.github.com>
Copilot AI changed the title Fix CodeQL code scanning: re-enable disabled workflow and pin .NET SDK version Fix CodeQL workflow: pin .NET SDK and scope restore to android-only Mar 26, 2026
…QL build

Using -f net9.0-android doesn't prevent MSBuild from evaluating and
importing workloads for ALL declared TargetFrameworks (including ios and
maccatalyst) during project SDK evaluation. This happens before the
framework selector takes effect.

Using /p:TargetFrameworks=net9.0-android overrides the property at the
command-line level (highest MSBuild priority), so the SDK only sees
net9.0-android during evaluation and doesn't try to import unavailable
iOS/macCatalyst workloads.

Also build only the library project instead of the full solution, since
DemoApp code isn't needed for CodeQL security analysis.

Agent-Logs-Url: https://github.com/trimble-oss/modus-mobile-maui-components/sessions/bcc76a04-3fd6-4b59-beb1-97abd429b4af

Co-authored-by: jeff-at-trimble <215895768+jeff-at-trimble@users.noreply.github.com>
Copilot AI changed the title Fix CodeQL workflow: pin .NET SDK and scope restore to android-only Fix CodeQL workflow: override TargetFrameworks to prevent iOS workload errors on Ubuntu Mar 26, 2026
@github-advanced-security

Copy link
Copy Markdown
Contributor

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

@jeff-at-trimble
jeff-at-trimble merged commit c6c5939 into develop Mar 26, 2026
5 checks passed
@jeff-at-trimble
jeff-at-trimble deleted the copilot/investigate-codeql-issues branch March 26, 2026 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants